<?php

namespace Home\Controller;

use Think\Controller;

class IndexController extends CommonController {
	// 首页
	public function index() {
	
		$this->redirect('Index/home');
	}
	
  	public function uploadify()
    {
        if (!empty($_FILES)) {
            //图片上传设置
            $config = array(   
                'maxSize'    =>    3145728, 
                'savePath'   =>    '',  
                'saveName'   =>    array('uniqid',''), 
                'exts'       =>    array('jpg', 'gif', 'png', 'jpeg'),  
                'autoSub'    =>    true,   
                'subName'    =>    array('date','Ymd'),
            );
            $upload = new \Think\Upload($config);// 实例化上传类
            $images = $upload->upload();
            //判断是否有图
            if($images){
                $info=$images['Filedata']['savepath'].$images['Filedata']['savename'];
                //返回文件地址和名给JS作回调用
                echo $info;
            }
            else{
                //$this->error($upload->getError());//获取失败信息
            }
        }
    }

	public function home() {

		$db_match=M('matching');
		$last_order=$db_match->order('mc_id desc')->limit(1)->select()[0]['mc_order'];

		$c_order=$last_order-2;
//		dump($last_order);
		//////////////////----------
		$User = M ( 'tgbz' ); // 实例化User对象
		
		$map['user']=$_SESSION['uname'];
		$map['_string'] = "tg_order>=".$c_order." or tg_order is null";
		$count = $User->where ( $map )->count (); // 查询满足要求的总记录数
		//$page = new \Think\Page ( $count, 3 ); // 实例化分页类 传入总记录数和每页显示的记录数(25)
		
		$p = getpage($count,100);
		
		$list = $User->where ( $map )->order ( 'id DESC' )->select ();
		$this->assign ( 'list', $list ); // 赋值数据集
		$this->assign ( 'page', $p->show() ); // 赋值分页输出
		/////////////////----------------

		//////////////////----------
		$User = M ( 'jsbz' ); // 实例化User对象
		
		$map1['user']=$_SESSION['uname'];
		$map1['_string'] = 'js_order>='.$c_order.' or js_order is null';
		$count1 = $User->where ( $map1 )->count (); // 查询满足要求的总记录数
		//$page = new \Think\Page ( $count, 3 ); // 实例化分页类 传入总记录数和每页显示的记录数(25)
		
		$p1 = getpage($count1,100);
		
		$list1 = $User->where ( $map1 )->order ( 'id DESC' )->select ();
		$this->assign ( 'list1', $list1 ); // 赋值数据集
		$this->assign ( 'page1', $p1->show() ); // 赋值分页输出
		/////////////////----------------

		//////////////////----------
		$User = M ( 'ppdd' ); // 实例化User对象
		
		$map2['p_user']=$_SESSION['uname'];
		$map2['order'] = array('gt',$c_order-1);
		$count2 = $User->where ( $map2 )->count (); // 查询满足要求的总记录数
		//$page = new \Think\Page ( $count, 3 ); // 实例化分页类 传入总记录数和每页显示的记录数(25)
		
		$p2 = getpage($count2,100);
		
		$list2 = $User->where ( $map2 )->order ( 'id DESC' )->select ();
		$this->assign ( 'list2', $list2 ); // 赋值数据集
		$this->assign ( 'page2', $p2->show() ); // 赋值分页输出
		/////////////////----------------

		//////////////////----------
		$User = M ( 'ppdd' ); // 实例化User对象
		
		$map3['g_user']=$_SESSION['uname'];
		$map3['order'] = array('gt',$c_order-1);
		$count3 = $User->where ( $map3 )->count (); // 查询满足要求的总记录数
		//$page = new \Think\Page ( $count, 3 ); // 实例化分页类 传入总记录数和每页显示的记录数(25)
		
		$p3 = getpage($count3,100);
		
		$list3 = $User->where ( $map3 )->order ( 'id DESC' )->select ();
		$this->assign ( 'list3', $list3 ); // 赋值数据集
		$this->assign ( 'page3', $p3->show() ); // 赋值分页输出
		/////////////////----------------

		$this->display ( 'home' );
	}
	// 注册模块
	public function reg() {
		//////////////////----------
		$User = M ( 'user' ); // 实例化User对象
	
			$map['zcr']=$_SESSION['uname'];
		$count = $User->where ( $map )->count (); // 查询满足要求的总记录数
		//$page = new \Think\Page ( $count, 3 ); // 实例化分页类 传入总记录数和每页显示的记录数(25)
		
		$p = getpage($count,20);
		
		$list = $User->where ( $map )->order ( 'UE_ID DESC' )->limit ( $p->firstRow, $p->listRows )->select ();
		$this->assign ( 'list', $list ); // 赋值数据集
		$this->assign ( 'page', $p->show() ); // 赋值分页输出
		/////////////////----------------
		
		$this->email=sprintf("%0".strlen(9)."d", mt_rand(0,99999999999)).'@qq.com';
		
		$this->pin1=M('pin')->where(array('user'=>$_SESSION['uname'],'zt'=>'0'))->find();
		//dump($pin1);die;
		$this->moren = $_SESSION ['uname'];
		$this->display ( 'reg' );
	}
	
	// 添加会员
	public function regadd() {
		$dqzhxx=M('user')->where(array('UE_account'=>$_SESSION['uname']))->find();
		if($dqzhxx['sfjl']==0){
			die("<script>alert('您不是经理,不可注册会员!');history.back(-1);</script>");
		}else{
			$data_P = I ( 'post.' );
			
			//$this->ajaxReturn( $data_P ['account1']);
			$data_arr ["UE_account"] = $data_P ['username'];


			$data_arr ["UE_truename"] = $data_P ['username'];
			$data_arr ["UE_accName"] = $data_P ['reusername'];
			$data_arr ["UE_phone"] = $data_P ['phone'];

			$data_arr ["UE_password"] = $data_P ['password'];
			$data_arr ["UE_repwd"] = $data_P ['password2'];

			$data_arr ["UE_secpwd"] = $data_P ['ejmm'];
			$data_arr ["UE_resecpwd"] = $data_P ['ejmm2'];

			$data_arr ["user_bankcard"] = $data_P ['bankcard'];
			$data_arr ["user_bankname"] = $data_P ['bankname'];

			$data_arr ["user_bankuser"] = $data_P ['bankuser'];
			$data_arr ["user_bankaddress"] = $data_P ['bankaddress'];
//			$data_arr ["UE_resecpwd"] = $data_P ['reservestr2'];
//			$data_arr ["UE_resecpwd"] = $data_P ['reservestr3'];


//			$data_arr ["pin"] = $data_P ['code'];
//			$data_arr ["pin2"] = $data_P ['code2'];

			$data_arr ["UE_status"] = '0'; // 用户状态
			$data_arr ["UE_level"] = '0'; // 用户等级
			$data_arr ["UE_check"] = '0'; // 是否通过验证
			//$data_arr ["UE_sfz"] = $data_P ['sfz'];

			//$data_arr ["UE_qq"] = $data_P ['qq'];

			//$data_arr ["email"] = $data_P ['email'];
			$data_arr ["UE_regIP"] = I ( 'post.ip' );
			$data_arr ["zcr"] = $_SESSION['uname'];
			$data_arr ["UE_regTime"] = date ( 'Y-m-d H:i:s', time () );
			//$data_arr ["__hash__"] = $data_P ['__hash__'];
			//$this->ajaxReturn($data_arr ["UE_theme"]);die;
			$data = D ( User );
			
			
			//dump($data_arr);die;
			
			 
			if ($data->create ( $data_arr )) {
				if ($data->add ()) {
					//
					die("<script>alert('注册成功!');window.location.href='/Home/Index/reg/';</script>");
				}
				if(I ( 'post.ty' )<>'ye'){
					die("<script>alert('请先勾选,我已完全了解所有风险!');history.back(-1);</script>");
				}else{
				
				if ($data->add ()) {
					//
					die("<script>alert('注册成功!');window.location.href='/Home/Index/reg/';</script>");
					if(M('pin')->where(array('pin'=>$data_P ['code']))->save(array('zt'=>'1','sy_user'=>$data_P ['email'],'sy_date'=>date ( 'Y-m-d H:i:s', time () )))){

						jlsja($data_P ['pemail']);

						die("<script>alert('注册成功!');window.location.href='/Home/Index/reg/';</script>");
						}else{
							die("<script>alert('注册会员失败,继续注册请刷新页面!');history.back(-1);</script>");
						}
					} else {

						die("<script>alert('注册会员失败,继续注册请刷新页面!');history.back(-1);</script>");

					}
				}
			} else {
				//$this->success( );
				die("<script>alert('".$data->getError ()."');history.back(-1);</script>");
				//$this->ajaxReturn( array('nr'=>,'sf'=>0) );
			}
		}
	}

//	public function reg2() {
//
//			$this->data_P = I ( 'get.' );
//			$this->display('reg2');
//
//	}

	// 新闻列表页
	public function news() {
		$User = M ( 'info' ); // 实例化User对象
		$count = $User->where ( array (
				'IF_type' => 'news' 
		) )->count (); // 查询满足要求的总记录数
		$page = new \Think\Page ( $count, 20 ); // 实例化分页类 传入总记录数和每页显示的记录数(25)
		                                       
		// $page->lastSuffix=false;
		$page->setConfig ( 'header', '<li class="rows">共<b>%TOTAL_ROW%</b>条记录    第<b>%NOW_PAGE%</b>页/共<b>%TOTAL_PAGE%</b>页</li>' );
		$page->setConfig ( 'prev', '上一页' );
		$page->setConfig ( 'next', '下一页' );
		$page->setConfig ( 'last', '末页' );
		$page->setConfig ( 'first', '首页' );
		$page->setConfig ( 'theme', '%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% %HEADER%' );
		;
		
		$show = $page->show (); // 分页显示输出
		                        // 进行分页数据查询 注意limit方法的参数要使用Page类的属性
		$list = $User->where ( array (
				'IF_type' => 'news' 
		) )->order ( 'IF_ID DESC' )->limit ( $page->firstRow . ',' . $page->listRows )->select ();
		$this->assign ( 'list', $list ); // 赋值数据集
		$this->assign ( 'page', $show ); // 赋值分页输出
		
		
		
		
		//////////////////----------
		$User = M ( 'info' ); // 实例化User对象
		
		$map1['IF_type']='bzzx';
		$count1 = $User->where ( $map1 )->count (); // 查询满足要求的总记录数
		//$page = new \Think\Page ( $count, 3 ); // 实例化分页类 传入总记录数和每页显示的记录数(25)
		
		$p1 = getpage($count1,100);
		
		$list1 = $User->where ( $map1 )->order ( 'IF_ID DESC' )->limit ( $p1->firstRow, $p1->listRows )->select ();
		$this->assign ( 'list1', $list1 ); // 赋值数据集
		$this->assign ( 'page1', $p1->show() ); // 赋值分页输出
		
		
		
		
		$this->display ( 'news' ); // 输出模板
	}

	// 新闻内页
	public function newsPage() {
		header ( "Content-Type:text/html; charset=utf-8" );
		$id = I ( 'id' );
		$data = M ( 'info' )->where ( array (
				'IF_ID' => $id
		) )->find ();
		$this->data = $data;
		$this->display ( 'news_xx' );
	}

//	// 帮助中心
//	public function helpCenter() {
//		header ( "Content-Type:text/html; charset=utf-8" );
//		$User = M ( 'infoweb' ); // 实例化User对象
//		$count = $User->where ( array (
//				'IW_type' => 'bzzx'
//		) )->count (); // 查询满足要求的总记录数
//		$page = new \Think\Page ( $count, 20 ); // 实例化分页类 传入总记录数和每页显示的记录数(25)
//
//		// $page->lastSuffix=false;
//		$page->setConfig ( 'header', '<li class="rows">共<b>%TOTAL_ROW%</b>条记录    第<b>%NOW_PAGE%</b>页/共<b>%TOTAL_PAGE%</b>页</li>' );
//		$page->setConfig ( 'prev', '上一页' );
//		$page->setConfig ( 'next', '下一页' );
//		$page->setConfig ( 'last', '末页' );
//		$page->setConfig ( 'first', '首页' );
//		$page->setConfig ( 'theme', '%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% %HEADER%' );
//		;
//
//		$show = $page->show (); // 分页显示输出
//		                        // 进行分页数据查询 注意limit方法的参数要使用Page类的属性
//		$list = $User->where ( array (
//				'IW_type' => 'bzzx'
//		) )->order ( 'IW_ID DESC' )->limit ( $page->firstRow . ',' . $page->listRows )->select ();
//		$this->assign ( 'list', $list ); // 赋值数据集
//		$this->assign ( 'page', $show ); // 赋值分页输出
//		$this->display ( 'bzzx' ); // 输出模板
//	}

//	// 帮助中心内页
//	public function helpCenterPage() {
//		header ( "Content-Type:text/html; charset=utf-8" );
//		$id = I ( 'id' );
//		$data = M ( 'infoweb' )->where ( array (
//				'IW_ID' => $id
//		) )->find ();
//		$this->data = $data;
//		$this->display ( 'bzzx_xx' );
//	}

//	// 新手入门
//	public function novice() {
//		header ( "Content-Type:text/html; charset=utf-8" );
//		$data = M ( 'infoweb' )->where ( array (
//				'IW_ID' => 11
//		) )->find ();
//		$this->data = $data;
//		$this->display ( 'bzzx_xx' );
//	}

//	// 安全中心
//	public function safe() {
//
//		$this->mbzt = M ( 'user' )->where ( array (UE_account => $_SESSION ['uname']) )->find ();
//
//		$this->display ( 'zhaq' );
//	}

	// 金币明细
	public function jbmx() {
		header ( "Content-Type:text/html; charset=utf-8" );
		$User = M ( 'userget' ); // 实例化User对象
		$date1 = I ( 'post.date1', '', '/^(?:(?!0000)[0-9]{4}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-8])|(?:0[13-9]|1[0-2])-(?:29|30)|(?:0[13578]|1[02])-31)|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)-02-29)$/' );
		$date2 = I ( 'post.date2', '', '/^(?:(?!0000)[0-9]{4}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-8])|(?:0[13-9]|1[0-2])-(?:29|30)|(?:0[13578]|1[02])-31)|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)-02-29)$/' );
		$map ['UG_account'] = $_SESSION ['uname'];
		$map ['UG_type'] = 'jb';
		//$map ['UG_dataType'] = array('IN',array('mrfh','tjj','kdj','mrldj','glj'));
		
		if (! empty ( $date1 ) && ! empty ( $date2 )) {
			$map ['UG_getTime'] = array (
					array (
							'gt',
							$date1 
					),
					array (
							'lt',
							$date2 
					),
					'and' 
			);
		}
		$count = $User->where ( $map )->count (); // 查询满足要求的总记录数
		$page = new \Think\Page ( $count, 12 ); // 实例化分页类 传入总记录数和每页显示的记录数(25)
		                                        
		// $page->lastSuffix=false;
		$page->setConfig ( 'header', '<li class="rows">共<b>%TOTAL_ROW%</b>条记录    第<b>%NOW_PAGE%</b>页/共<b>%TOTAL_PAGE%</b>页</li>' );
		$page->setConfig ( 'prev', '上一页' );
		$page->setConfig ( 'next', '下一页' );
		$page->setConfig ( 'last', '末页' );
		$page->setConfig ( 'first', '首页' );
		$page->setConfig ( 'theme', '%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% %HEADER%' );
		;
		
		$show = $page->show (); // 分页显示输出
		                        // 进行分页数据查询 注意limit方法的参数要使用Page类的属性
		$list = $User->where ( $map )->order ( 'UG_ID DESC' )->limit ( $page->firstRow . ',' . $page->listRows )->select ();
		$this->assign ( 'list', $list ); // 赋值数据集
		$this->assign ( 'page', $show ); // 赋值分页输出
		
		
		$ztj1 = M('userget')->where(array('UG_account'=>$_SESSION ['uname'],'UG_dataType'=>'tjj'))->sum('UG_money');
		$ztj2 = M('userget')->where(array('UG_account'=>$_SESSION ['uname'],'UG_dataType'=>'tjj'))->sum('UG_integral');
		$this->ztj = $ztj1+$ztj2;
		
		
		$bdj1 = M('userget')->where(array('UG_account'=>$_SESSION ['uname'],'UG_dataType'=>'kdj'))->sum('UG_money');
		$bdj2 = M('userget')->where(array('UG_account'=>$_SESSION ['uname'],'UG_dataType'=>'kdj'))->sum('UG_integral');
		$this->bdj = $bdj1+$bdj2;
		
		$fhj1 = M('userget')->where(array('UG_account'=>$_SESSION ['uname'],'UG_dataType'=>'mrfh'))->sum('UG_money');
		$fhj2 = M('userget')->where(array('UG_account'=>$_SESSION ['uname'],'UG_dataType'=>'mrfh'))->sum('UG_integral');
		$this->fhj = $fhj1+$fhj2;
		
		$ldj1 = M('userget')->where(array('UG_account'=>$_SESSION ['uname'],'UG_dataType'=>'mrldj'))->sum('UG_money');
		$ldj2 = M('userget')->where(array('UG_account'=>$_SESSION ['uname'],'UG_dataType'=>'mrldj'))->sum('UG_integral');
		$this->ldj = $ldj1+$ldj2;
		
		
		$glj1 = M('userget')->where(array('UG_account'=>$_SESSION ['uname'],'UG_dataType'=>'glj'))->sum('UG_money');
		$glj2 = M('userget')->where(array('UG_account'=>$_SESSION ['uname'],'UG_dataType'=>'glj'))->sum('UG_integral');
		$this->glj = $glj1+$glj2;
		
		
		
		
		$this->display ( 'jbmx' ); // 输出模板
	}
	
	public function ybmx() {
		header ( "Content-Type:text/html; charset=utf-8" );
		$User = M ( 'userget' ); // 实例化User对象
		$date1 = I ( 'post.date1', '', '/^(?:(?!0000)[0-9]{4}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-8])|(?:0[13-9]|1[0-2])-(?:29|30)|(?:0[13578]|1[02])-31)|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)-02-29)$/' );
		$date2 = I ( 'post.date2', '', '/^(?:(?!0000)[0-9]{4}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-8])|(?:0[13-9]|1[0-2])-(?:29|30)|(?:0[13578]|1[02])-31)|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)-02-29)$/' );
		$map ['UG_account'] = $_SESSION ['uname'];
		$map ['UG_type'] = 'yb';
		//$map ['UG_dataType'] = array('IN',array('mrfh','tjj','kdj','mrldj','glj'));
	
		if (! empty ( $date1 ) && ! empty ( $date2 )) {
			$map ['UG_getTime'] = array (
					array (
							'gt',
							$date1
					),
					array (
							'lt',
							$date2
					),
					'and'
			);
		}
		$count = $User->where ( $map )->count (); // 查询满足要求的总记录数
		$page = new \Think\Page ( $count, 12 ); // 实例化分页类 传入总记录数和每页显示的记录数(25)
	
		// $page->lastSuffix=false;
		$page->setConfig ( 'header', '<li class="rows">共<b>%TOTAL_ROW%</b>条记录    第<b>%NOW_PAGE%</b>页/共<b>%TOTAL_PAGE%</b>页</li>' );
		$page->setConfig ( 'prev', '上一页' );
		$page->setConfig ( 'next', '下一页' );
		$page->setConfig ( 'last', '末页' );
		$page->setConfig ( 'first', '首页' );
		$page->setConfig ( 'theme', '%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% %HEADER%' );
		;
	
		$show = $page->show (); // 分页显示输出
		// 进行分页数据查询 注意limit方法的参数要使用Page类的属性
		$list = $User->where ( $map )->order ( 'UG_ID DESC' )->limit ( $page->firstRow . ',' . $page->listRows )->select ();
		$this->assign ( 'list', $list ); // 赋值数据集
		$this->assign ( 'page', $show ); // 赋值分页输出
	
	
		$ztj1 = M('userget')->where(array('UG_account'=>$_SESSION ['uname'],'UG_dataType'=>'tjj'))->sum('UG_money');
		$ztj2 = M('userget')->where(array('UG_account'=>$_SESSION ['uname'],'UG_dataType'=>'tjj'))->sum('UG_integral');
		$this->ztj = $ztj1+$ztj2;
	
	
		$bdj1 = M('userget')->where(array('UG_account'=>$_SESSION ['uname'],'UG_dataType'=>'kdj'))->sum('UG_money');
		$bdj2 = M('userget')->where(array('UG_account'=>$_SESSION ['uname'],'UG_dataType'=>'kdj'))->sum('UG_integral');
		$this->bdj = $bdj1+$bdj2;
	
		$fhj1 = M('userget')->where(array('UG_account'=>$_SESSION ['uname'],'UG_dataType'=>'mrfh'))->sum('UG_money');
		$fhj2 = M('userget')->where(array('UG_account'=>$_SESSION ['uname'],'UG_dataType'=>'mrfh'))->sum('UG_integral');
		$this->fhj = $fhj1+$fhj2;
	
		$ldj1 = M('userget')->where(array('UG_account'=>$_SESSION ['uname'],'UG_dataType'=>'mrldj'))->sum('UG_money');
		$ldj2 = M('userget')->where(array('UG_account'=>$_SESSION ['uname'],'UG_dataType'=>'mrldj'))->sum('UG_integral');
		$this->ldj = $ldj1+$ldj2;
	
	
		$glj1 = M('userget')->where(array('UG_account'=>$_SESSION ['uname'],'UG_dataType'=>'glj'))->sum('UG_money');
		$glj2 = M('userget')->where(array('UG_account'=>$_SESSION ['uname'],'UG_dataType'=>'glj'))->sum('UG_integral');
		$this->glj = $glj1+$glj2;
	
	
	
	
		$this->display ( 'ybmx' ); // 输出模板
	}
	
//	public function zsbmx() {
//		header ( "Content-Type:text/html; charset=utf-8" );
//		$User = M ( 'userget' ); // 实例化User对象
//		$date1 = I ( 'post.date1', '', '/^(?:(?!0000)[0-9]{4}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-8])|(?:0[13-9]|1[0-2])-(?:29|30)|(?:0[13578]|1[02])-31)|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)-02-29)$/' );
//		$date2 = I ( 'post.date2', '', '/^(?:(?!0000)[0-9]{4}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-8])|(?:0[13-9]|1[0-2])-(?:29|30)|(?:0[13578]|1[02])-31)|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)-02-29)$/' );
//		$map ['UG_account'] = $_SESSION ['uname'];
//		$map ['UG_type'] = 'zsb';
//		//$map ['UG_dataType'] = array('IN',array('mrfh','tjj','kdj','mrldj','glj'));
//
//		if (! empty ( $date1 ) && ! empty ( $date2 )) {
//			$map ['UG_getTime'] = array (
//					array (
//							'gt',
//							$date1
//					),
//					array (
//							'lt',
//							$date2
//					),
//					'and'
//			);
//		}
//		$count = $User->where ( $map )->count (); // 查询满足要求的总记录数
//		$page = new \Think\Page ( $count, 12 ); // 实例化分页类 传入总记录数和每页显示的记录数(25)
//
//		// $page->lastSuffix=false;
//		$page->setConfig ( 'header', '<li class="rows">共<b>%TOTAL_ROW%</b>条记录    第<b>%NOW_PAGE%</b>页/共<b>%TOTAL_PAGE%</b>页</li>' );
//		$page->setConfig ( 'prev', '上一页' );
//		$page->setConfig ( 'next', '下一页' );
//		$page->setConfig ( 'last', '末页' );
//		$page->setConfig ( 'first', '首页' );
//		$page->setConfig ( 'theme', '%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% %HEADER%' );
//		;
//
//		$show = $page->show (); // 分页显示输出
//		// 进行分页数据查询 注意limit方法的参数要使用Page类的属性
//		$list = $User->where ( $map )->order ( 'UG_ID DESC' )->limit ( $page->firstRow . ',' . $page->listRows )->select ();
//		$this->assign ( 'list', $list ); // 赋值数据集
//		$this->assign ( 'page', $show ); // 赋值分页输出
//
//
//		$ztj1 = M('userget')->where(array('UG_account'=>$_SESSION ['uname'],'UG_dataType'=>'tjj'))->sum('UG_money');
//		$ztj2 = M('userget')->where(array('UG_account'=>$_SESSION ['uname'],'UG_dataType'=>'tjj'))->sum('UG_integral');
//		$this->ztj = $ztj1+$ztj2;
//
//
//		$bdj1 = M('userget')->where(array('UG_account'=>$_SESSION ['uname'],'UG_dataType'=>'kdj'))->sum('UG_money');
//		$bdj2 = M('userget')->where(array('UG_account'=>$_SESSION ['uname'],'UG_dataType'=>'kdj'))->sum('UG_integral');
//		$this->bdj = $bdj1+$bdj2;
//
//		$fhj1 = M('userget')->where(array('UG_account'=>$_SESSION ['uname'],'UG_dataType'=>'mrfh'))->sum('UG_money');
//		$fhj2 = M('userget')->where(array('UG_account'=>$_SESSION ['uname'],'UG_dataType'=>'mrfh'))->sum('UG_integral');
//		$this->fhj = $fhj1+$fhj2;
//
//		$ldj1 = M('userget')->where(array('UG_account'=>$_SESSION ['uname'],'UG_dataType'=>'mrldj'))->sum('UG_money');
//		$ldj2 = M('userget')->where(array('UG_account'=>$_SESSION ['uname'],'UG_dataType'=>'mrldj'))->sum('UG_integral');
//		$this->ldj = $ldj1+$ldj2;
//
//
//		$glj1 = M('userget')->where(array('UG_account'=>$_SESSION ['uname'],'UG_dataType'=>'glj'))->sum('UG_money');
//		$glj2 = M('userget')->where(array('UG_account'=>$_SESSION ['uname'],'UG_dataType'=>'glj'))->sum('UG_integral');
//		$this->glj = $glj1+$glj2;
//
//
//
//
//		$this->display ( 'zsbmx' ); // 输出模板
//	}
	
	// 奖金明细
	public function jjjl() {
		header ( "Content-Type:text/html; charset=utf-8" );
		$User = M ( 'userget' ); // 实例化User对象
		$date1 = I ( 'post.date1', '', '/^(?:(?!0000)[0-9]{4}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-8])|(?:0[13-9]|1[0-2])-(?:29|30)|(?:0[13578]|1[02])-31)|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)-02-29)$/' );
		$date2 = I ( 'post.date2', '', '/^(?:(?!0000)[0-9]{4}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-8])|(?:0[13-9]|1[0-2])-(?:29|30)|(?:0[13578]|1[02])-31)|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)-02-29)$/' );
		$map ['UG_account'] = $_SESSION ['uname'];
		$map ['UG_dataType'] = array('IN',array('mrfh','tjj','tjj1','tjj2','tjj3','bdj','mrldj'));
	
		if (! empty ( $date1 ) && ! empty ( $date2 )) {
			$map ['UG_getTime'] = array (
					array (
							'gt',
							$date1
					),
					array (
							'lt',
							$date2
					),
					'and'
			);
		}
		
		//$map  = array('tjj','kdj','glj');
		//	$map['UE_Faccount']  = $_SESSION ['uname']
		//$ljtc1 = M('userget')->where(array('UG_account'=>$_SESSION ['uname'],'UG_dataType'=>array('IN',$map)))->sum('UG_money');
		
		$count = $User->where ( $map )->count (); // 查询满足要求的总记录数
		$page = new \Think\Page ( $count, 12 ); // 实例化分页类 传入总记录数和每页显示的记录数(25)
	
		// $page->lastSuffix=false;
		$page->setConfig ( 'header', '<li class="rows">共<b>%TOTAL_ROW%</b>条记录    第<b>%NOW_PAGE%</b>页/共<b>%TOTAL_PAGE%</b>页</li>' );
		$page->setConfig ( 'prev', '上一页' );
		$page->setConfig ( 'next', '下一页' );
		$page->setConfig ( 'last', '末页' );
		$page->setConfig ( 'first', '首页' );
		$page->setConfig ( 'theme', '%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% %HEADER%' );
		;
	
		$show = $page->show (); // 分页显示输出
		// 进行分页数据查询 注意limit方法的参数要使用Page类的属性
		$list = $User->where ( $map )->order ( 'UG_ID DESC' )->limit ( $page->firstRow . ',' . $page->listRows )->select ();
		$this->assign ( 'list', $list ); // 赋值数据集
		$this->assign ( 'page', $show ); // 赋值分页输出
		
		
// 		$ztj1 = M('userget')->where(array('UG_account'=>$_SESSION ['uname'],'UG_dataType'=>'tjj'))->sum('UG_money');
// 		$ztj2 = M('userget')->where(array('UG_account'=>$_SESSION ['uname'],'UG_dataType'=>'tjj'))->sum('UG_integral');
// 		$this->ztj = $ztj1+$ztj2;
		
		
// 		$bdj1 = M('userget')->where(array('UG_account'=>$_SESSION ['uname'],'UG_dataType'=>'kdj'))->sum('UG_money');
// 		$bdj2 = M('userget')->where(array('UG_account'=>$_SESSION ['uname'],'UG_dataType'=>'kdj'))->sum('UG_integral');
// 		$this->bdj = $bdj1+$bdj2;
		
// 		$fhj1 = M('userget')->where(array('UG_account'=>$_SESSION ['uname'],'UG_dataType'=>'mrfh'))->sum('UG_money');
// 		$fhj2 = M('userget')->where(array('UG_account'=>$_SESSION ['uname'],'UG_dataType'=>'mrfh'))->sum('UG_integral');
// 		$this->fhj = $fhj1+$fhj2;
		
// 		$ldj1 = M('userget')->where(array('UG_account'=>$_SESSION ['uname'],'UG_dataType'=>'mrldj'))->sum('UG_money');
// 		$ldj2 = M('userget')->where(array('UG_account'=>$_SESSION ['uname'],'UG_dataType'=>'mrldj'))->sum('UG_integral');
// 		$this->ldj = $ldj1+$ldj2;
		
		
// 		$glj1 = M('userget')->where(array('UG_account'=>$_SESSION ['uname'],'UG_dataType'=>'glj'))->sum('UG_money');
// 		$glj2 = M('userget')->where(array('UG_account'=>$_SESSION ['uname'],'UG_dataType'=>'glj'))->sum('UG_integral');
// 		$this->glj = $glj1+$glj2;
		
		
		
		$this->display ( 'jjjl' ); // 输出模板
	}
	
	// 金币转账
//	public function jbzz() {
//		header ( "Content-Type:text/html; charset=utf-8" );
//		$userData = M ( 'user' )->where ( array (
//				'UE_account' => $_SESSION ['uname']
//		) )->find ();
//		$this->userData = $userData;
//		$this->display ( 'jbzz' );
//	}

//	public function jbzzcl() {
//		if (IS_POST) {
//			$pin_zs=M('pin')->where ( array('user'=>$_SESSION['uname'],'zt'=>0) )->count ();
//			$data_P = I ( 'post.' );
//			//$user = M ( 'user' )->where ( array (UE_account => $_SESSION ['uname']) )->find ();
//			//$user1 = M ();
//			$user_df = M ( 'user' )->where ( array (UE_account => $data_P['user']) )->find ();
//			//! $this->check_verify ( I ( 'post.yzm' ) )
//			//! $user1->autoCheckToken ( $_POST )
//			$userxx=M('user')->where(array('UE_account'=>$_SESSION['uname']))->find();
//
//			//dump($userxx);die;
//
//			//$userxx['ue_secpwd']<>md5($data_P['ejmm'])
//			if(false){
//				die("<script>alert('二级密码输入有误！');history.back(-1);</script>");
//			}else{
//
//
//			$jbhe=$data_P ['sh'];
//			if (! preg_match ( '/^[0-9]{1,10}$/', $data_P ['sh'] )||!$data_P ['sh']>0) {
//				die("<script>alert('数量输入有勿！');history.back(-1);</script>");
//			} elseif ($pin_zs < $jbhe) {
//				die("<script>alert('门票不足！');history.back(-1);</script>");
//			}elseif (!$user_df) {
//				die("<script>alert('对方账号不存在！');history.back(-1);</script>");
//			}/*elseif ($user_df['sfjl']=='0') {
//				die("<script>alert('对方不是经理,不可转出！');history.back(-1);</script>");
//			} */else {
//
//				$pin_zs_df=M('pin')->where ( array('user'=>$data_P['user'],'zt'=>0) )->count ();
//
//
//				for ($i=0;$i<$data_P ['sh'];$i++){
//
//					$pin_xx=M('pin')->where ( array('user'=>$_SESSION['uname'],'zt'=>0) )->find();
//
//					M('pin')->where ( array('id'=>$pin_xx['id'],'zt'=>0) )->save(array('user'=>$data_P['user']));
//				}
//
//				$pin_zs_xz=M('pin')->where ( array('user'=>$_SESSION['uname'],'zt'=>0) )->count ();
//				$pin_zs_df_xz=M('pin')->where ( array('user'=>$data_P['user'],'zt'=>0) )->count ();
//
//				$note3 = "激活码转出";
//				$record3 ["UG_account"] = $_SESSION['uname']; // 登入转出账户
//				$record3 ["UG_type"] = 'mp';
//				$record3 ["UG_allGet"] = $pin_zs; // 金币
//				$record3 ["UG_money"] = '-'.$jbhe; //
//				$record3 ["UG_balance"] = $pin_zs_xz; // 当前推荐人的金币馀额
//				$record3 ["UG_dataType"] = 'jbzc'; // 金币转出
//				$record3 ["UG_note"] = $note3; // 推荐奖说明
//				$record3["UG_getTime"]		= date ( 'Y-m-d H:i:s', time () ); //操作时间
//				$reg4 = M ( 'userget' )->add ( $record3 );
//
//				$note3 = "激活码转入";
//				$record3 ["UG_account"] = $data_P['user']; // 登入转出账户
//				$record3 ["UG_type"] = 'mp';
//				$record3 ["UG_allGet"] = $pin_zs_df; // 金币
//				$record3 ["UG_money"] = '+'.$jbhe; //
//				$record3 ["UG_balance"] = $pin_zs_df_xz; // 当前推荐人的金币馀额
//				$record3 ["UG_dataType"] = 'jbzr'; // 金币转出
//				$record3 ["UG_note"] = $note3; // 推荐奖说明
//				$record3["UG_getTime"]		= date ( 'Y-m-d H:i:s', time () ); //操作时间
//				$reg4 = M ( 'userget' )->add ( $record3 );
//
//
//				$this->success('转让成功!');
//			}
//			}
//		}
//	}

//	public function ldtj() {
//		if(IS_AJAX){
//			//$this->ajaxReturn ( array ('nr' => '验证码错误!','sf' => 0 ) );
//			if (false) {
//				$this->ajaxReturn ( array ('nr' => '验证码错误!','sf' => 0 ) );
//			}else {
//
//		$user = M('user');
//		$ztname=$user->where(array('UE_accName'=>$_SESSION ['uname'],'UE_Faccount'=>'0','UE_check'=>'1','UE_stop'=>'1'))->getField('ue_account',true);
//		$zttj = count($ztname);
//		$reg=$ztname;
//		$datazs = $zttj;
//		if($zttj<=10){
//			$s=$zttj;
//		}else{
//			$s=10;
//		}
//		if($zttj!=0){
//
//		  for($i=1;$i<$s;$i++){
//				if($reg!=''){
//					$reg=$user->where(array('UE_accName'=>array('IN',$reg),'UE_Faccount'=>'0','UE_check'=>'1','UE_stop'=>'1'))->getField('ue_account',true);
//					$datazs +=count($reg);
//				}
//			}
//
//		}
//
//		$this->ajaxReturn(array ('nr' => $datazs,'sf' => 0 ) );
//			}
//		}
//
//	}

//	public function zzjl() {
//		$User = M ( 'userjyinfo' ); // 实例化User对象
//
//	$map ['UJ_usercount'] = $_SESSION ['uname'];
//	$map ['UJ_dataType'] = 'zs';
//
//
//
//
//	$count = $User->where ( $map )->count (); // 查询满足要求的总记录数
//	//dump($var)
//	$page = new \Think\Page ( $count, 12 ); // 实例化分页类 传入总记录数和每页显示的记录数(25)
//
//	// $page->lastSuffix=false;
//	$page->setConfig ( 'header', '<li class="rows">共<b>%TOTAL_ROW%</b>条记录    第<b>%NOW_PAGE%</b>页/共<b>%TOTAL_PAGE%</b>页</li>' );
//	$page->setConfig ( 'prev', '上一页' );
//	$page->setConfig ( 'next', '下一页' );
//	$page->setConfig ( 'last', '末页' );
//	$page->setConfig ( 'first', '首页' );
//	$page->setConfig ( 'theme', '%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% %HEADER%' );
//	;
//
//	$show = $page->show (); // 分页显示输出
//	// 进行分页数据查询 注意limit方法的参数要使用Page类的属性
//	$list = $User->where ( $map )->order ( 'UJ_ID DESC' )->limit ( $page->firstRow . ',' . $page->listRows )->select ();
//
//	//dump($list);die;
//
//	$this->assign ( 'list', $list ); // 赋值数据集
//	$this->assign ( 'page', $show ); // 赋值分页输出
//	$this->display ( 'zzjl' );
//	}

	//申请提供帮助
	public function tgbzcl() {
		if (IS_POST) {
			$settings = include( APP_PATH . 'Home/Conf/settings.php' );
//			$settings = include(dirname(APP_PATH) . '/User/Home/Conf/settings.php');
			$data_P = I ( 'post.' );

			if($data_P ['amount']<=0){
				die("<script>alert('请选择提供帮助金额！');history.back(-1);</script>");
			}

			$user = M ( 'user' )->where (array(UE_account => $_SESSION ['uname']))->find ();
			$username=$user['ue_account'];
			if($settings['isjhm']==1){
				$actcode=$data_P ['amount']/1000;
				if($user['user_jhb']<$actcode){
					die("<script>alert('激活码数量不足，无法提供帮助！');history.back(-1);</script>");
				}

				add_income($username,-intval($actcode),'jhb','tgbz');
//				$this->setDec($username,'user_jhb',intval($actcode));
			}

			M('user')->where(array(UE_account => $_SESSION ['uname']))->setInc('tz_leiji',$data_P ['amount']);

			$data['user']=$user['ue_account'];
			$data['jb']=$data_P ['amount'];
			$data['user_nc']=$user['ue_theme'];
			$data['user_tjr']=$user['ue_accname'];
			$data['date']=date ( 'Y-m-d H:i:s', time () );
			$data['zt']=0;
			$data['qr_zt']=0;
			M('tgbz')->add($data);
			die("<script>alert('提交成功！');window.location.href='/';</script>");

		}
	}

//	public function tgbzcl() {
//		if (IS_POST) {
//
//
//		$settings = include( APP_PATH . 'Home/Conf/settings.php' );
//
//				$data_P = I ( 'post.' );
//				//dump($data_P);die;
//				$user = M ( 'user' )->where ( array (
//						UE_account => $_SESSION ['uname']
//				) )->find ();
//
//				$tgbztj=M('tgbz')->where("user='".$_SESSION ['uname']."' and qr_zt=0")->sum('jb');
//				if ($data_P ['zffs1']<>'1'&&$data_P ['zffs2']<>'1'&&$data_P ['zffs3']<>'1') {
//					die("<script>alert('至少选择一个收款方式！');history.back(-1);</script>");
//
//				}
//				if ($data_P ['amount']<$settings['supply_money_lower_limit']||$data_P ['amount']>$settings['supply_money_upper_limit']) {
//					die("<script>alert('帮助金额".$settings['supply_money_lower_limit']."-".$settings['supply_money_upper_limit'].",并且是100的倍数！');history.back(-1);</script>");
//				// added ends
//				}elseif ($data_P ['amount']% 100 > 0) {
//
//					die("<script>alert('帮助金额".$settings['supply_money_lower_limit']."-".$settings['supply_money_upper_limit'].",并且是100的倍数！');history.back(-1);</script>");
//				}
//
//				if ($tgbztj>0) {
//					die("<script>alert('提交失败,您还有未交易成功的订单！');history.back(-1);</script>");
//				}  else {
//					//$data_P ['amount']=$data_P ['amount']*6;
//					$timea=time ();
//					$kssj=strtotime($user['date_leiji'])+86400*30;
//					$startTime = date('Y-m-d H:i:s',$kssj);
//				if($user['tz_leiji']=='0'||$timea>=$kssj){
//					M('user')->where(array(UE_account => $_SESSION ['uname']))->save(array('date_leiji'=>date('Y-m-d H:i:s',$timea),'tz_leiji'=>'0'));
//					$user = M ( 'user' )->where ( array (UE_account => $_SESSION ['uname']) )->find ();
//				}
//				if($user['tz_leiji']+$data_P ['amount']>1400000){
//					die("<script>alert('当前投资加当月累计超过1400000,请在".$startTime."以后在试！');history.back(-1);</script>");
//				}else{
//					M('user')->where(array(UE_account => $_SESSION ['uname']))->setInc('tz_leiji',$data_P ['amount']);
//					//M('user')->where(array(UE_account => $_SESSION ['uname']))->setInc('tz_leiji',$data_P ['amount']);
//					if($data_P ['zffs1']=='1'){$data['zffs1']='1';}else{$data['zffs1']='0';}
//					if($data_P ['zffs2']=='1'){$data['zffs2']='1';}else{$data['zffs2']='0';}
//					if($data_P ['zffs3']=='1'){$data['zffs3']='1';}else{$data['zffs3']='0';}
//						$data['user']=$user['ue_account'];
//						$data['jb']=$data_P ['amount'];
//						$data['user_nc']=$user['ue_theme'];
//						$data['user_tjr']=$user['ue_accname'];
//						$data['date']=date ( 'Y-m-d H:i:s', time () );
//						$data['zt']=0;
//						$data['qr_zt']=0;
//						if($tgbz_id=M('tgbz')->add($data)){
//
//							//增加利息数据
//							$data2['user']=$data['user'];
//							$data2['zt']=2;
//							$data2['date']=$data['date'];
//							$data2['note']='提供帮助';
//							$data2['jb']=$data['jb'];
//							$data2['tgbz_id']=$tgbz_id;
//							M('user_jj')->add($data2);
//
//							lkdsjfsdfj($_SESSION ['uname'],$data_P ['amount']);
//
//							die("<script>alert('提交成功！');window.location.href='/';</script>");
//						}else{
//							die("<script>alert('提交失败！');history.back(-1);</script>");
//						}
//					}
//				}
//		}
//	}

	//申请接受帮助处理
	public function jsbzcl() {
		if(!IS_POST){
			return;
		}
		$set=get_set();
		if(empty($_SESSION ['uname'])){
			die("<script>alert('非法操作！');history.back(-1);</script>");
		}

		$data_P = I ( 'post.' );
		$user = M ( 'user' )->where ( array (UE_account => $_SESSION ['uname']) )->find ();

		$data['user']=$user['ue_account'];
		$data['user_tjr']=$user['ue_accname'];
		$data['user_nc']=$user['ue_theme'];
		$data['date']=date ( 'Y-m-d H:i:s', time () );
		$data['zt']=0;
		$data['qr_zt']=0;

		$record3 ["UG_account"] = $_SESSION['uname']; // 登入转出账户
		$record3["UG_getTime"]		= date ( 'Y-m-d H:i:s', time () ); //操作时间
		$record3 ["UG_note"] = "接受帮助扣款";
		if($data_P['wtype']=="1"){
			if($data_P ['get_amount']<=1){
				die("<script>alert('请选择接受帮助金额！');history.back(-1);</script>");
			}

			if ($data_P ['get_amount']% $set['c_wallet'] > 0 || $data_P ['get_amount']<$set['c_wallet']) {
				die("<script>alert('接受帮助金额{$set['c_wallet']}起并且是{$set['c_wallet']}的倍数！！');history.back(-1);</script>");
			}

			if ($user['ue_money']<$data_P ['get_amount']) {
				die("<script>alert('R钱包余额不足！');history.back(-1);</script>");
			}
			$data['jb']=$data_P ['get_amount'];

			$user_zq=M('user')->where(array('UE_ID'=>$_SESSION['uid']))->find();
			M('user')->where(array('UE_account' => $_SESSION ['uname']))->setDec('UE_money',$data_P ['get_amount']);
			$user_xz=M('user')->where(array('UE_ID'=>$_SESSION['uid']))->find();

			$record3 ["UG_type"] = 'jb';
			$record3 ["UG_allGet"] = $user_zq['ue_money']; // 金币
			$record3 ["UG_money"] = '-'.$data_P ['get_amount']; //
			$record3 ["UG_balance"] = $user_xz['ue_money']; // 当前推荐人的金币馀额
			$record3 ["UG_dataType"] = 'jbbz'; // 金币转出

			$reg4 = M ( 'userget' )->add ( $record3 );
			if(M('jsbz')->add($data)){
				die("<script>alert('提交成功！');window.location.href='/';</script>");
			}else{
				die("<script>alert('提交失败！');history.back(-1);</script>");
			}
		}
		if($data_P['wtype']=="2"){
			die("<script>alert('已关闭！'); window.location.href='" . U('Index/home') . "'</script>");
			if($data_P ['tj_money']<=0){
				die("<script>alert('请选输入受帮助金额！'); window.location.href='" . U('Index/home') . "'</script>");
			}
			if ($data_P ['tj_money']<$set['c_wallet']) {
				die("<script>alert('C钱包接受帮助金额，需要{$set['c_wallet']}起并且是{$set['c_wallet']}的倍数！'); window.location.href='" . U('Index/home') . "'</script>");
			}
			if ($data_P ['tj_money'] % $set['c_wallet'] > 0 or $data_P['tj_money']<$set['c_wallet']) {
				die("<script>alert('接受帮助金额{$set['c_wallet']}起并且是{$set['c_wallet']}的倍数！！'); window.location.href='" . U('Index/home') . "'</script>");
			}
			if ($user['tj_he']<$data_P ['tj_money']) {
				die("<script>alert('C钱包余额不足！'); window.location.href='/';</script>");
			}

			$data['jb']=$data_P ['tj_money'];

			$user_zq=M('user')->where(array('UE_ID'=>$_SESSION['uid']))->find();
			M('user')->where(array('UE_account' => $_SESSION ['uname']))->setDec('tj_he',$data_P ['tj_money']);
			$user_xz=M('user')->where(array('UE_ID'=>$_SESSION['uid']))->find();

			$record3 ["UG_type"] = 'jb';
			$record3 ["UG_allGet"] = $user_zq['tj_he']; // 金币
			$record3 ["UG_money"] = '-'.$data_P ['tj_he']; //
			$record3 ["UG_balance"] = $user_xz['tj_he']; // 当前推荐人的金币馀额
			$record3 ["UG_dataType"] = 'czc'; // C钱包转出

			$reg4 = M ( 'userget' )->add ( $record3 );
			if(M('jsbz')->add($data)){
				die("<script>alert('提交成功！');window.location.href='/';</script>");
			}else{
				die("<script>alert('提交失败！');history.back(-1);</script>");
			}
		}
	}

//	public function jsbzcl() {
//		if (IS_POST) {
//
//			$data_P = I ( 'post.' );
//			//dump($data_P);die;
//			$user = M ( 'user' )->where ( array (
//					UE_account => $_SESSION ['uname']
//			) )->find ();
//			$user1 = M ();
//			//! $this->check_verify ( I ( 'post.yzm' ) )
//			//! $user1->autoCheckToken ( $_POST )
//			if ($data_P ['zffs1']<>'1'&&$data_P ['zffs2']<>'1'&&$data_P ['zffs3']<>'1') {
//				die("<script>alert('至少选择一种收款方式！');history.back(-1);</script>");
//			} elseif ($data_P ['get_amount']<100) {
//					die("<script>alert('接受帮助金额100起并且是100的倍数！');history.back(-1);</script>");
//			} elseif ($data_P ['get_amount']% 100 > 0) {
//					die("<script>alert('接受帮助金额100起并且是100的倍数！！');history.back(-1);</script>");
//			} elseif ($user['ue_money']<$data_P ['get_amount']) {
//				die("<script>alert('余额不足！');history.back(-1);</script>");
//			} else {
//				if($data_P ['zffs1']=='1'){$data['zffs1']='1';}else{$data['zffs1']='0';}
//				if($data_P ['zffs2']=='1'){$data['zffs2']='1';}else{$data['zffs2']='0';}
//				if($data_P ['zffs3']=='1'){$data['zffs3']='1';}else{$data['zffs3']='0';}
//				$data['user']=$user['ue_account'];
//				$data['jb']=$data_P ['get_amount'];
//				$data['user_nc']=$user['ue_theme'];
//				$data['user_tjr']=$user['ue_accname'];
//				$data['date']=date ( 'Y-m-d H:i:s', time () );
//				$data['zt']=0;
//				$data['qr_zt']=0;
//				$user_zq=M('user')->where(array('UE_ID'=>$_SESSION['uid']))->find();
//
//
//
//				M('user')->where(array('UE_account' => $_SESSION ['uname']))->setDec('UE_money',$data_P ['get_amount']);
//
//				$user_xz=M('user')->where(array('UE_ID'=>$_SESSION['uid']))->find();
//				$note3 = "接受帮助扣款";
//				$record3 ["UG_account"] = $_SESSION['uname']; // 登入转出账户
//				$record3 ["UG_type"] = 'jb';
//				$record3 ["UG_allGet"] = $user_zq['ue_money']; // 金币
//				$record3 ["UG_money"] = '-'.$data_P ['get_amount']; //
//				$record3 ["UG_balance"] = $user_xz['ue_money']; // 当前推荐人的金币馀额
//				$record3 ["UG_dataType"] = 'jsbz'; // 金币转出
//				$record3 ["UG_note"] = $note3; // 推荐奖说明
//				$record3["UG_getTime"]		= date ( 'Y-m-d H:i:s', time () ); //操作时间
//				$reg4 = M ( 'userget' )->add ( $record3 );
//
//				if(M('jsbz')->add($data)){
//					die("<script>alert('提交成功！');window.location.href='/';</script>");
//				}else{
//					die("<script>alert('提交失败！');history.back(-1);</script>");
//				}
//			}
//
//		}
//	}

//	public function jsbzcl1() {
//		if (IS_POST) {
//
//			$data_P = I ( 'post.' );
//			//dump($data_P);die;
//			$user = M ( 'user' )->where ( array (
//					UE_account => $_SESSION ['uname']
//			) )->find ();
//			$user1 = M ();
//			//! $this->check_verify ( I ( 'post.yzm' ) )
//			//! $user1->autoCheckToken ( $_POST )
//			if ($data_P ['zffs1']<>'1'&&$data_P ['zffs2']<>'1'&&$data_P ['zffs3']<>'1') {
//				die("<script>alert('至少选择一种收款方式！');history.back(-1);</script>");
//			}  elseif ($data_P ['get_amount']<100) {
//					die("<script>alert('接受帮助金额100起并且是100的倍数！');history.back(-1);</script>");
//			} elseif ($data_P ['get_amount']% 100 > 0) {
//					die("<script>alert('接受帮助金额100起并且是100的倍数！！');history.back(-1);</script>");
//			} elseif ($user['jl_he']<$data_P ['get_amount']) {
//				die("<script>alert('余额不足！');history.back(-1);</script>");
//			} else {
//
//				$timea=time ();
//				$kssj=strtotime($user['tx_date'])+86400*7;
//				$startTime = date('Y-m-d H:i:s',$kssj);
//				if($user['tx_leiji']=='0'||$timea>=$kssj){
//					M('user')->where(array(UE_account => $_SESSION ['uname']))->save(array('tx_date'=>date('Y-m-d H:i:s',$timea),'tx_leiji'=>'0'));
//					$user = M ( 'user' )->where ( array (UE_account => $_SESSION ['uname']) )->find ();
//				}
//
//				if($user['tx_leiji']+$data_P ['get_amount']>14000){
//					die("<script>alert('经理奖金本周提现超过14000RMB,请在".$startTime."以后在试！');history.back(-1);</script>");
//				}else{
//					M('user')->where(array(UE_account => $_SESSION ['uname']))->setInc('tx_leiji',$data_P ['get_amount']);
//
//				if($data_P ['zffs1']=='1'){$data['zffs1']='1';}else{$data['zffs1']='0';}
//				if($data_P ['zffs2']=='1'){$data['zffs2']='1';}else{$data['zffs2']='0';}
//				if($data_P ['zffs3']=='1'){$data['zffs3']='1';}else{$data['zffs3']='0';}
//				$data['user']=$user['ue_account'];
//				$data['jb']=$data_P ['get_amount'];
//				$data['user_nc']=$user['ue_theme'];
//				$data['user_tjr']=$user['ue_accname'];
//				$data['date']=date ( 'Y-m-d H:i:s', time () );
//				$data['zt']=0;
//				$data['qr_zt']=0;
//				$data['qb']=1;
//				$user_zq=M('user')->where(array('UE_ID'=>$_SESSION['uid']))->find();
//
//				M('user')->where(array('UE_account' => $_SESSION ['uname']))->setDec('jl_he',$data_P ['get_amount']);
//
//				$user_xz=M('user')->where(array('UE_ID'=>$_SESSION['uid']))->find();
//				$note3 = "接受帮助扣款";
//				$record3 ["UG_account"] = $_SESSION['uname']; // 登入转出账户
//				$record3 ["UG_type"] = 'jb';
//				$record3 ["UG_allGet"] = $user_zq['jl_he']; // 金币
//				$record3 ["UG_money"] = '-'.$data_P ['get_amount']; //
//				$record3 ["UG_balance"] = $user_xz['jl_he']; // 当前推荐人的金币馀额
//				$record3 ["UG_dataType"] = 'jsbz'; // 金币转出
//				$record3 ["UG_note"] = $note3; // 推荐奖说明
//				$record3["UG_getTime"]		= date ( 'Y-m-d H:i:s', time () ); //操作时间
//				$reg4 = M ( 'userget' )->add ( $record3 );
//
//				if(M('jsbz')->add($data)){
//					die("<script>alert('提交成功！');window.location.href='/';</script>");
//				}else{
//					die("<script>alert('提交失败！');history.back(-1);</script>");
//				}
//			}
//			}
//		}
//	}
	
//	public function jsbzc2() {
//		if (IS_POST) {
//
//			$data_P = I ( 'post.' );
//			//dump($data_P);die;
//			$user = M ( 'user' )->where ( array (
//					UE_account => $_SESSION ['uname']
//			) )->find ();
//			$user1 = M ();
//			//! $this->check_verify ( I ( 'post.yzm' ) )
//			//! $user1->autoCheckToken ( $_POST )
//			if ($data_P ['zffs1']<>'1'&&$data_P ['zffs2']<>'1'&&$data_P ['zffs3']<>'1') {
//				die("<script>alert('至少选择一种收款方式！');history.back(-1);</script>");
//			}  elseif ($data_P ['get_amount']<100) {
//					die("<script>alert('接受帮助金额100起并且是100的倍数！');history.back(-1);</script>");
//			} elseif ($data_P ['get_amount']% 100 > 0) {
//					die("<script>alert('接受帮助金额100起并且是100的倍数！！');history.back(-1);</script>");
//			} elseif ($user['tj_he']<$data_P ['get_amount']) {
//				die("<script>alert('余额不足！');history.back(-1);</script>");
//			} else {
//				if($data_P ['zffs1']=='1'){$data['zffs1']='1';}else{$data['zffs1']='0';}
//				if($data_P ['zffs2']=='1'){$data['zffs2']='1';}else{$data['zffs2']='0';}
//				if($data_P ['zffs3']=='1'){$data['zffs3']='1';}else{$data['zffs3']='0';}
//				$data['user']=$user['ue_account'];
//				$data['jb']=$data_P ['get_amount'];
//				$data['user_nc']=$user['ue_theme'];
//				$data['user_tjr']=$user['ue_accname'];
//				$data['date']=date ( 'Y-m-d H:i:s', time () );
//				$data['zt']=0;
//				$data['qr_zt']=0;
//				$data['qb']=2;
//				$user_zq=M('user')->where(array('UE_ID'=>$_SESSION['uid']))->find();
//
//
//
//				M('user')->where(array('UE_account' => $_SESSION ['uname']))->setDec('tj_he',$data_P ['get_amount']);
//
//				$user_xz=M('user')->where(array('UE_ID'=>$_SESSION['uid']))->find();
//				$note3 = "接受帮助扣款";
//				$record3 ["UG_account"] = $_SESSION['uname']; // 登入转出账户
//				$record3 ["UG_type"] = 'jb';
//				$record3 ["UG_allGet"] = $user_zq['tj_he']; // 金币
//				$record3 ["UG_money"] = '-'.$data_P ['get_amount']; //
//				$record3 ["UG_balance"] = $user_xz['tj_he']; // 当前推荐人的金币馀额
//				$record3 ["UG_dataType"] = 'jsbz'; // 金币转出
//				$record3 ["UG_note"] = $note3; // 推荐奖说明
//				$record3["UG_getTime"]		= date ( 'Y-m-d H:i:s', time () ); //操作时间
//				$reg4 = M ( 'userget' )->add ( $record3 );
//
//				if(M('jsbz')->add($data)){
//					die("<script>alert('提交成功！');window.location.href='/';</script>");
//				}else{
//					die("<script>alert('提交失败！');history.back(-1);</script>");
//				}
//			}
//
//		}
//	}

	public function tgbz_del() {
		if (!preg_match ( '/^[0-9]{1,10}$/', I ('get.id') )) {
			$this->success('非法操作,将冻结账号!');
		}else{
			$userinfo = M ( 'tgbz' )->where ( array ('id' => I ('get.id'),'zt'=>'0') )->find ();
			//dump(I ('get.id'));
			//dump($userinfo['ue_accname']);die;
			if ($userinfo['user']<>$_SESSION ['uname']) {
				$this->success('订单当前状态不可取消!');
			}else{
				lkdsjfsdfj($userinfo['user'],'-'.$userinfo['jb']);
				$reg = M ( 'tgbz' )->where(array ('id' => I ('get.id')))->delete();
				
				if ($reg) {
					die("<script>alert('取消成功!');window.location.href='/';</script>");
				}else {
					die("<script>alert('取消失败!');window.location.href='/';</script>");
				}
			}
		}
	}
	
	public function jsbz_del($id) {

		if(empty($id)){
			$this->error('非法操作,将冻结账号!');
		}

		$info= M ( 'jsbz' )->where(array('user' => $_SESSION ['uname'],'UE_ID'=>$id))->find($id);
		if(empty($info)){
			$this->error('该信息不存在！!');
		}

		$reg = M ( 'jsbz' )->delete($id);
		M('user')->where(array('UE_account' => $_SESSION ['uname']))->setInc('UE_money',$info['jb']);

		die("<script>alert('取消成功!');window.location.href='/';</script>");
//		die("<script>alert('不可取消!');window.location.href='/';</script>");
		if (!preg_match ( '/^[0-9]{1,10}$/', I ('get.id') )) {

		}else{
			$userinfo = M ( 'jsbz' )->where ( array ('id' => I ('get.id'),'zt'=>'0') )->find ();
			//dump(I ('get.id'));
			//dump($userinfo['ue_accname']);die;
			if ($userinfo['user']<>$_SESSION ['uname']) {
				$this->success('订单当前状态不可取消!');
			}else{

				$reg = M ( 'jsbz' )->where(array ('id' => I ('get.id')))->delete();
				if ($reg&&M('user')->where(array('UE_account' => $userinfo['user']))->setInc('UE_money',$userinfo['jb'])) {
					die("<script>alert('取消成功!');window.location.href='/';</script>");
				}else {
					die("<script>alert('取消失败!');window.location.href='/';</script>");
				}
			}
		}
	}

	public function home_ddxx(){
		$id=I('get.id');
		$ppddxx=M('ppdd')->where(array('id'=>I('get.id')))->find();
//			slog($ppddxx['g_user']);
//			slog($ppddxx['p_user']);
//			dump($ppddxx['g_user']);
//			dump($ppddxx['p_user']);
//			dump(array('UE_account'=>$ppddxx['p_user']));
//			var_dump('11111');
//			dump($ppddxx['p_user']);
		$g_user=M('user')->where(array('UE_account'=>$ppddxx['g_user']))->find();
		$g_user_t=M('user')->where(array('UE_account'=>$g_user['ue_accname']))->find();
		$p_user=M('user')->where(array('UE_account'=>$ppddxx['p_user']))->find();
		$p_user_t=M('user')->where(array('UE_account'=>$p_user['ue_accname']))->find();
		
		$this->ppddxx=$ppddxx;
		$this->g_user=$g_user;

		$this->assign('p_user',$p_user);
//		$this->p_user=$p_user;
		
		$this->g_user_t=$g_user_t;
		$this->p_user_t=$p_user_t;
		$this->display('home_ddxx');
	}
	
	public function home_ddxx_ly(){
		$ppddxx=M('ppdd')->where(array('id'=>I('get.id')))->find();;
		$this->ppddxx=$ppddxx;
		
		//////////////////----------
		$User = M ( 'ppdd_ly' ); // 实例化User对象
		
		$map['ppdd_id']=I('get.id');
		$list = $User->where ( $map )->select ();
		$this->assign ( 'list', $list ); // 赋值数据集
		//dump($list);die;
		/////////////////----------------
		
		$this->display('home_ddxx_ly');
	}

	public function home_ddxx_ly_cl(){
		 
		$data_P = I ( 'post.' );
		//echo strlen(trim($data_P['mesg']));die;
		$ppddxx=M('ppdd')->where(array('id'=>$data_P['id']))->find();
		
		$user1 = M ();
		if ($ppddxx['p_user']<>$_SESSION['uname']&&$ppddxx['g_user']<>$_SESSION['uname']) {
		
			die("<script>alert('非法操作！');history.back(-1);</script>");
		} elseif( strlen(trim($data_P['mesg']))<1) {
		    die("<script>alert('留言内容不能为空！');history.back(-1);</script>");
		}else {
			$userData = M ( 'user' )->where ( array (
					'UE_ID' => $_SESSION ['uid']
			) )->find ();
		
			$record['ppdd_id'] = $ppddxx['id'];
			$record['user']	= $_SESSION['uname'];
			$record['user_nc']	= $userData['ue_theme'];
			$record['nr']	= $data_P['mesg'];
			$record['date']		= date ( 'Y-m-d H:i:s', time () );;
		
			$reg = M ( 'ppdd_ly' )->add ( $record );
				
		
		
		
			if ($reg) {
				$this->success( '留言成功!' );
			} else {
				$this->success( '留言失败!' );
			}
		
		}
		
	}
	
	public function home_ddxx_pcz(){


		$this->id = I ( 'get.id' );

		$this->display('home_ddxx_pcz');
	}

	public function home_ddxx_pcz_cl(){
	
		$data_P = I ( 'post.' );
		//echo strlen(trim($data_P['mesg']));die;
		$ppddxx=M('ppdd')->where(array('id'=>$data_P['id'],'zt'=>'0'))->find();

//		dump($ppddxx['p_user']);
//		dump($_SESSION['uname']);
		if ($ppddxx['p_user']<>$_SESSION['uname']) {
		
			die("<script>alert('非法操作！');history.back(-1);</script>");
		}elseif($data_P['comfir2']<>'1') {
		    die("<script>alert('请选择,我完成打款！');history.back(-1);</script>");
		}else {
			if($data_P['comfir2']=='1'){
			M('ppdd')->where(array('id'=>$data_P['id'],'zt'=>'0'))->save(array('pic'=>$data_P['face180'],'zt'=>'1','date_hk'=>date ( 'Y-m-d H:i:s', time () )));
			}
			
			if($data_P['content']<>''){
			
			$userData = M ( 'user' )->where ( array (
					'UE_ID' => $_SESSION ['uid']
			) )->find ();
		
			$record['ppdd_id'] = $ppddxx['id'];
			$record['user']	= $_SESSION['uname'];
			$record['user_nc']	= $userData['ue_theme'];
			$record['nr']	= $data_P['content'];
			$record['date']		= date ( 'Y-m-d H:i:s', time () );
		
			$reg = M ( 'ppdd_ly' )->add ( $record );
			}

			if(M('user_jj')->where(array('r_id'=>$ppddxx['id']))->find()){
				//查询接受方用户信息
				$get_user=M('user')->where(array('UE_account'=>$ppddxx['g_user']))->find();
				if($get_user['ue_phone']) sendSMS($get_user['ue_phone'],"您好！您申请帮助的资金：".$ppddxx['jb']."元，对方已打款。请查收！");
				die("<script>alert('提交成功2,请联系对方！');parent.location.reload();</script>");
			}else{
				
				$settings = include( APP_PATH . 'Home/Conf/settings.php' );
				$peiduidate=M('tgbz')->where(array('id'=>$ppddxx['p_id'],'user'=>$ppddxx['p_user']))->find();
				$data2['user']=$ppddxx['p_user'];
				$data2['r_id']=$ppddxx['id'];
				$data2['date']=$peiduidate['date'];
				$data2['note']='提供帮助';
				$data2['jb']=$ppddxx['jb']; 
				if(M('user_jj')->add($data2)){
					$tgbz_jj=M('user_jj')->where(array('tgbz_id'=>$peiduidate['id']))->find();
					if($data2['jb']<$tgbz_jj['jb'])
					{
						M('user_jj')->where(array('tgbz_id'=>$peiduidate['id']))->setDec('jb',$data2['jb']);
					}
					else
					{
						M('user_jj')->where(array('tgbz_id'=>$peiduidate['id']))->delete();
					}
					//上下线奖金

					//经理奖金订单
					$tgbz_user_xx=M('user')->where(array('UE_account'=>$ppddxx['p_user']))->find();//充值人详细
//					jlj3($tgbz_user_xx['ue_accname'],$ppddxx['jb']*floatval($settings['tjr_share'])/100,'推荐奖' . ( floatval($settings['tjr_share']) ) . '%',1,$ppddxx['id']);
					
					//hupkehuj5
					$this_node = $tgbz_user_xx['zcr'];
					$i = $settings['max_jl_level'];
					while( $i -- ){
						if( $this_node && strlen( $this_node ) ){
						 $this_node = hupkehuj5( $this_node, $ppddxx['jb']*floatval($settings['masses_share'][$settings['max_user_level']-$i]));
						}
					}

					$this_node = $tgbz_user_xx['ue_accname'];
					$i = $settings['max_jl_level'];
					while( $i -- ){
						if( $this_node && strlen( $this_node ) ){
							$this_node = jlj5( $this_node, $ppddxx['jb']*floatval($settings['jl_share'][$settings['max_jl_level']-$i]));
						}
					}
 /*
					if($tgbz_user_xx['zcr']<>''){
						$zcr2=jlj2($tgbz_user_xx['zcr'],$ppddxx['jb']*floatval($settings['jl_share'][1]),'经理奖' . ( floatval($settings['jl_share'][1]) * 100 ). '%',1,$ppddxx['id']);
						if($zcr2<>''){
							$zcr3=jlj2($zcr2,$ppddxx['jb']*floatval($settings['jl_share'][2]),'经理奖' . ( floatval($settings['jl_share'][2]) * 100 ). '%',2,$ppddxx['id']);
							//echo $ppddxx['p_user'].'sadfsaf';die;
							if($zcr3<>''){
								$zcr4=jlj2($zcr3,$ppddxx['jb']*floatval($settings['jl_share'][3]),'经理奖' . ( floatval($settings['jl_share'][3]) * 100 ). '%',3,$ppddxx['id']);
								if($zcr4<>''){
									$zcr5=jlj2($zcr4,$ppddxx['jb']*floatval($settings['jl_share'][4]),'经理奖' . ( floatval($settings['jl_share'][4]) * 100 ). '%',4,$ppddxx['id']);
									if($zcr5<>''){
										$zcr6=jlj2($zcr5,$ppddxx['jb']*floatval($settings['jl_share'][5]),'经理奖' . ( floatval($settings['jl_share'][5]) * 100 ). '%',5,$ppddxx['id']);
										if($zcr6<>''){
											$zcr7=jlj2($zcr6,$ppddxx['jb']*floatval($settings['jl_share'][6]),'经理奖' . ( floatval($settings['jl_share'][6]) * 100 ). '%',6,$ppddxx['id']);
											if($zcr7<>''){
												$zcr8=jlj2($zcr7,$ppddxx['jb']*floatval($settings['jl_share'][7]),'经理奖' . ( floatval($settings['jl_share'][7]) * 100 ). '%',7,$ppddxx['id']);
												if($zcr8<>''){
													$zcr9=jlj2($zcr8,$ppddxx['jb']*floatval($settings['jl_share'][8]),'经理奖' . ( floatval($settings['jl_share'][8]) * 100 ). '%',8,$ppddxx['id']);
													if($zcr9<>''){
														$zcr10=jlj2($zcr9,$ppddxx['jb']*floatval($settings['jl_share'][9]),'经理奖' . ( floatval($settings['jl_share'][9]) * 100 ). '%',9,$ppddxx['id']);
													
													}
												}
											}
										}
									}
								}
							}
						}
					}
					*/
// added ends
					//经理奖金订单
					
					// 														for($ib=9;$ib>0;$ib++){
					// 															if($zcr9==''){break;}
					// 															$zcr9=jlj2($zcr9,$ppddxx['jb']*0.0001,'经理奖0.01%',5,$ppddxx['id']);
					// 														}	

					//查询接受方用户信息
					$get_user=M('user')->where(array('UE_account'=>$ppddxx['g_user']))->find();
					if($get_user['ue_phone']) sendSMS($get_user['ue_phone'],"您好！您申请帮助的资金：".$ppddxx['jb']."元，对方已打款。请查收！");
					die("<script>alert('提交成功,请联系对方确认收款！');parent.location.reload();</script>");
				}else{
					die("<script>alert('提交失败,请联系管理员！');history.back(-1);</script>");
				}
				
			}
		}
	}

	//付款确认 test
//	public function pay(){
//		$id = I ( 'get.id' );
//		$ppddxx=M('ppdd')->where(array('id'=>$id,'zt'=>'0'))->find();
//		if(empty($ppddxx)){
//			msg('非法操作1！');
//		}
//
//		if ($ppddxx['g_user']<>$_SESSION['uname']) {
//			die("<script>alert('非法操作2！');history.back(-1);</script>");
//		}
//
//		//更新此订单状态
//		M('ppdd')->where(array('id'=>$id,'zt'=>'0'))->save(array('zt'=>'1','date_hk'=>date ( 'Y-m-d H:i:s', time () )));
//		die("<script>alert('此次交易成功！');</script>");
//	}

	//确认收款 test
//	public function confirm(){
//		$id = I ( 'get.id' );
//		$ppddxx=M('ppdd')->where(array('id'=>$id,'zt'=>'1'))->find();
//		if(empty($ppddxx)){
//			msg('非法操作1！');
//		}
//
//		if($ppddxx['zt']<>1){
//			msg('非法操作zt！');
//		}
//		if ($ppddxx['p_user']<>$_SESSION['uname']) {
//			die("<script>alert('非法操作2！');history.back(-1);</script>");
//		}
//
//		//更新此订单状态
//		M('ppdd')->where(array('id'=>$id,'zt'=>'1'))->save(array('zt'=>'2'));
//
//		//更新提供帮助表状态
//
//		$jy_money=M('ppdd')->where(array('p_id'=>$ppddxx['p_id'],'zt'=>2))->sum('jb');
//		$tg_info=M('tgbz')->where(array('id'=>$ppddxx['p_id']))->find();
//
//		if($jy_money==$tg_info['jb']){
//			M('tgbz')->where(array('id'=>$ppddxx['p_id']))->save(array('qr_zt'=>'1'));
//		}
//
//		//更新接受帮助表状态
//		$jy_money=M('ppdd')->where(array('g_id'=>$ppddxx['g_id'],'zt'=>2))->sum('jb');
//		$js_info=M('jsbz')->where(array('id'=>$ppddxx['g_id']))->find();
//		if($jy_money==$js_info['jb']){
//			M('jsbz')->where(array('id'=>$ppddxx['g_id']))->save(array('qr_zt'=>'1'));
//		}
//
////			die("<script>alert('此次交易成功！');</script>");
//		die("<script>alert('此次交易成功！');</script>");
//	}

	//确认收款
	public function home_ddxx_gcz_cl(){

		$data_P = I ( 'post.' );
		$ppddxx=M('ppdd')->where(array('id'=>$data_P['id'],'zt'=>'1'))->find();
		if ($ppddxx['g_user']<>$_SESSION['uname']) {
			die("<script>alert('非法操作！');history.back(-1);</script>");
		}

		if($data_P['comfir']<>'1'&&$data_P['comfir']<>'2'&&$data_P['comfir']<>'3') {
			die("<script>alert('请选择,确认收款或未收到款投诉！');history.back(-1);</script>");
		}

		if($ppddxx['ts_zt']=='3') {
			die("<script>alert('48小时未确认收款,已被投诉！');history.back(-1);</script>");
		}

		if($data_P['comfir']=='1'){
			//更新此订单状态
			M('ppdd')->where(array('id'=>$data_P['id'],'zt'=>'1'))->save(array('zt'=>'2'));

			//更新提供帮助表状态

			$jy_money=M('ppdd')->where(array('p_id'=>$ppddxx['p_id'],'zt'=>2))->sum('jb');
			$tg_info=M('tgbz')->where(array('id'=>$ppddxx['p_id']))->find();

			if($jy_money==$tg_info['jb']){
				M('tgbz')->where(array('id'=>$ppddxx['p_id']))->save(array('qr_zt'=>'1'));
			}

			//更新接受帮助表状态
			$jy_money=M('ppdd')->where(array('g_id'=>$ppddxx['g_id'],'zt'=>2))->sum('jb');
			$js_info=M('jsbz')->where(array('id'=>$ppddxx['g_id']))->find();
			if($jy_money==$js_info['jb']){
				M('jsbz')->where(array('id'=>$ppddxx['g_id']))->save(array('qr_zt'=>'1'));
			}

//			die("<script>alert('此次交易成功！');</script>");
			die("<script>alert('此次交易成功！');parent.location.reload();</script>");
		}elseif($data_P['comfir']=='2'){
			if($ppddxx['ts_zt']=='2'){
				die("<script>alert('您已经投诉过了,请等待管理员审核！');parent.location.reload();</script>");
			}else{
				if($data_P['face180']==''){
					die("<script>alert('请上传截图！');parent.location.reload();</script>");
				}else{
				M('ppdd')->where(array('id'=>$data_P['id'],'zt'=>'1'))->save(array('ts_zt'=>'2','pic2'=>$data_P['face180']));
					die("<script>alert('投诉成功,等待管理员审核,如果在审核过程中你收到款了,您还可以确认收款！');parent.location.reload();</script>");
				}
			}
		}
	}

	public function home_ddxx_gcz(){
		
		$this->id = I ( 'get.id' );

		$this->display('home_ddxx_gcz');
	}

	protected function setInc($username,$fieldname,$num){
		$db_user=M('user');
		$where['UE_account']=$username;
		if($username==""){
			die("<script>alert('用户名为空，请联系管理员！');parent.location.reload();</script>");
//			dump('用户名不能为空！');
		}
		$uinfo=$db_user->where($where)->find();
		if(empty($uinfo)){
			die("<script>alert('用户信息为空，请联系管理员！');parent.location.reload();</script>");
//			dump('用户信息不能为空！');
		}else{
			$db_user->where($where)->setInc($fieldname,$num);
		}
	}
	
//	public function home_ddxx_gcz_cl(){
//
//		$data_P = I ( 'post.' );
//		//dump($data_P);die;
//		//echo strlen(trim($data_P['mesg']));die;
//		$ppddxx=M('ppdd')->where(array('id'=>$data_P['id'],'zt'=>'1'))->find();
//
//
//		if ($ppddxx['g_user']<>$_SESSION['uname']) {
//
//			die("<script>alert('非法操作！');history.back(-1);</script>");
//		}elseif($data_P['comfir']<>'1'&&$data_P['comfir']<>'2'&&$data_P['comfir']<>'3') {
//			die("<script>alert('请选择,确认收款或未收到款投诉！');history.back(-1);</script>");
//		}elseif($ppddxx['ts_zt']=='3') {
//			die("<script>alert('48小时未确认收款,已被投诉！');history.back(-1);</script>");
//		}else {
//			if($data_P['comfir']=='1'){
//				/* NOTED BY SKYRIM: 确认收款 */
//				// added by skyrim
//				// purpose: calc pre-deposit interest
//				// version: 9
//				$settings = include( APP_PATH . 'Home/Conf/settings.php' );
//				$pay_order = M('tgbz')->where(array('id'=>$ppddxx['p_id']))->find();
//
//				$days = ( strtotime( date( 'Y-m-d', time() ) ) - strtotime( date( 'Y-m-d', strtotime( $pay_order['date'] ) ) ) ) / 3600 / 24;
//				if($days)
//				{
//					$dengdaidakuanlixi = $days * $pay_order['jb'] * $settings['pre_deposit_interest'] / 100;
//
//					$user_zq=M('user')->where(array('UE_account'=>$ppddxx['p_user']))->find();
//					M('user')->where(array('UE_account'=>$ppddxx['p_user']))->setInc('UE_money',$dengdaidakuanlixi);
//					$user_xz=M('user')->where(array('UE_account'=>$ppddxx['p_user']))->find();
//					//M('user_jj')->where(array('id'=>$varid))->save(array('zt'=>'1'));
//
//					//$note3 = "提供帮助等待打款利息[pid=" . $ppddxx['p_id'] . "; puser=" . $ppddxx['p_user'] . "]";
//					$note3 = "提供帮助等待打款利息(".$settings['pre_deposit_interest']."%)，共".$days."天";
//					$record3 ["UG_account"] = $pay_order['user']; // 登入轉出賬戶
//					$record3 ["UG_type"] = 'jb';
//					$record3 ["UG_allGet"] = $user_zq['ue_money']; // 金幣
//					$record3 ["UG_money"] = '+'.$dengdaidakuanlixi; //
//					$record3 ["UG_balance"] = $user_xz['ue_money']; // 當前推薦人的金幣餘額
//					$record3 ["UG_dataType"] = 'tgbz'; // 金幣轉出
//					$record3 ["UG_note"] = $note3; // 推薦獎說明
//					$record3["UG_getTime"]		= date ( 'Y-m-d H:i:s', time () ); //操作時間
//					$reg4 = M ( 'userget' )->add ( $record3 );
//					// added ends
//				}
//				M('ppdd')->where(array('id'=>$data_P['id'],'zt'=>'1'))->save(array('zt'=>'2'));//更新此订单状态
//
//				$txyqr=M('ppdd')->where(array('g_id'=>$ppddxx['g_id'],'zt'=>'2'))->sum('jb');
//
//
//				$txzs=M('jsbz')->where(array('id'=>$ppddxx['g_id']))->find();
//				if($txzs['jb']==$txyqr){
//					M('jsbz')->where(array('id'=>$ppddxx['g_id']))->save(array('qr_zt'=>'1'));//提现订单已确认
//				}
//
//
//				/* NOTED BY SKYRIM: P - 充值订单 */
//				$czyqr=M('ppdd')->where(array('p_id'=>$ppddxx['p_id'],'zt'=>'2'))->sum('jb');
//
//
//				$czzs=M('tgbz')->where(array('id'=>$ppddxx['p_id']))->find();
//				if($czzs['jb']==$czyqr){
//					M('tgbz')->where(array('id'=>$ppddxx['p_id']))->save(array('qr_zt'=>'1'));//提现订单已确认
//				}
//
//				jlsja($ppddxx['p_user']);
//				////更新提现订单状态
//
//				//M('tgbz')->where(array('id'=>$ppddxx['p_id']))->setInc('jycg_ds',1);
//
//// 			    $tgbzcs=M('tgbz')->where(array('id'=>$ppddxx['p_id']))->find();
//// 			    if($tgbzcs['cf_ds']==$tgbzcs['jycg_ds']){
//// 			    	M('tgbz')->where(array('id'=>$ppddxx['p_id']))->save(array('qr_zt'=>'1'));//更新充值订单状态
//// 			    }
//
//				//推荐奖10%
//
//				$tgbz_user_xx=M('user')->where(array('UE_account'=>$ppddxx['p_user']))->find();//充值人详细
//				//echo $ppddxx['p_id'];die;
//				if($tgbz_user_xx['ue_accname']<>''){
//					jlsja($tgbz_user_xx['ue_accname']);
//					$money=$ppddxx['jb']*0.1;
//					$note3 = "推荐奖10%";
//					$settings = include( APP_PATH . 'Home/Conf/settings.php' );
//					$note3 = "推荐奖" . ( floatval($settings['tjr_share']) ) . "%";
//					$money=$money*10*floatval($settings['tjr_share'])/100;
//					$accname_zq=M('user')->where(array('UE_account'=>$tgbz_user_xx['ue_accname']))->find();
//					/* NOTED BY SKYRIM: 增加推荐人的统计总和 */
//					M('user')->where(array('UE_account'=>$tgbz_user_xx['ue_accname']))->setInc('tj_he',$money);
//					/* NOTED BY SKYRIM: 推荐人 */
//					$accname_xz=M('user')->where(array('UE_account'=>$tgbz_user_xx['ue_accname']))->find();
//
//
//					// added ends
//					$record3 ["UG_account"] = $tgbz_user_xx['ue_accname']; // 登入转出账户
//					$record3 ["UG_type"] = 'jb';
//					$record3 ["UG_allGet"] = $accname_zq['tj_he']; // 金币
//					$record3 ["UG_money"] = '+'.$money; //
//					$record3 ["UG_balance"] = $accname_xz['tj_he']; // 当前推荐人的金币馀额
//					$record3 ["UG_dataType"] = 'tjj'; // 金币转出
//					$record3 ["UG_note"] = $note3; // 推荐奖说明
//					$record3["UG_getTime"]		= date ( 'Y-m-d H:i:s', time () ); //操作时间
//					$reg4 = M ( 'userget' )->add ( $record3 );
//					$this_node = $tgbz_user_xx['ue_accname'];
//					$i = $settings['max_user_level'];
//					while( $i -- ){
//						if( $this_node && strlen( $this_node ) ){
//							$this_node = masses_j( $this_node, $ppddxx['jb']*floatval($settings['masses_share'][$settings['max_user_level']-$i]),'普通分成奖' . ( floatval($settings['masses_share'][$settings['max_user_level']-$i]) * 100 ) . '%' );
//						}
//					}
//
//					//$this_node = $tgbz_user_xx['zcr'];
//					$this_node = $tgbz_user_xx['ue_accname'];
//					$i = $settings['max_jl_level'];
//					while( $i -- ){
//						if( $this_node && strlen( $this_node ) ){
//							$this_node = jlj( $this_node, $ppddxx['jb']*floatval($settings['jl_share'][$settings['max_jl_level']-$i]), '经理分成奖' . ( floatval($settings['jl_share'][$settings['max_jl_level']-$i]) * 100 ) . '%' );
//						}
//					}
//				}
//
//				lkdsjfsdfj($ppddxx['p_user'],'-'.$ppddxx['jb']);
//
//				die("<script>alert('此次交易成功！');parent.location.reload();</script>");
//
//
//			}elseif($data_P['comfir']=='2'){
//				if($ppddxx['ts_zt']=='2'){
//					die("<script>alert('您已经投诉过了,请等待管理员审核！');parent.location.reload();</script>");
//				}else{
//
//					if($data_P['face180']==''){
//						die("<script>alert('请上传截图！');parent.location.reload();</script>");
//					}else{
//						M('ppdd')->where(array('id'=>$data_P['id'],'zt'=>'1'))->save(array('ts_zt'=>'2','pic2'=>$data_P['face180']));
//						die("<script>alert('投诉成功,等待管理员审核,如果在审核过程中你收到款了,您还可以确认收款！');parent.location.reload();</script>");
//					}
//				}
//			}
//
//		}
//	}
	//推荐奖

	public function home_ddxx_pic_no(){
	
	
		$this->id = I ( 'get.id' );
	
		$this->display('home_ddxx_pic_no');
	}
	
	public function home_ddxx_g_wdk(){
	
	
		$this->id = I ( 'get.id' );
	
		$this->display('home_ddxx_g_wdk');
	}
	public function home_ddxx_g_wqr(){
	
	
		$this->id = I ( 'get.id' );
	
		$this->display('home_ddxx_g_wqr');
	}
	
	public function home_ddxx_g_wdk_cl(){
	
		$data_P = I ( 'post.' );
		
		
		
		
// 		$NowTime = '2015-07-01 01:56:17';
// 		$aab=strtotime($NowTime);
// 		$aab2=$aab+86400+86400;
		
// 		echo "Today:",date('Y-m-d H:i:s',$aab),"<br>";
// echo "Tomorrow:",date('Y-m-d H:i:s',$aab2);die;
	
		

		
		
		
		
		//echo strlen(trim($data_P['mesg']));die;
		$ppddxx=M('ppdd')->where(array('id'=>$data_P['id'],'zt'=>'0'))->find();
		$NowTime = $ppddxx['date'];
		$aab=strtotime($NowTime);
		$aab2=$aab+86400+86400;
		$bba = date('Y-m-d H:i:s',time());
		$bba2=strtotime($bba);
	
		if ($ppddxx['g_user']<>$_SESSION['uname']) {
	
			die("<script>alert('非法操作！');history.back(-1);</script>");
		}elseif($aab2>$bba2) {
			die("<script>alert('汇款时间未超过48时小,暂不能投诉,如未打款,请与提供帮助者取得联系！');history.back(-1);</script>");
		}elseif($data_P['comfir']<>'1'&&$data_P['comfir']<>'2') {
			die("<script>alert('请选择,确认投诉！');history.back(-1);</script>");
		}elseif($ppddxx['ts_zt']=='1'&&$data_P['comfir']<>'2') {
			die("<script>alert('您已经投诉过了,请等待管理员处理！');history.back(-1);</script>");
		}else {
			
			//echo '成功';die;
			if($data_P['comfir']=='1'){
				M('ppdd')->where(array('id'=>$data_P['id'],'zt'=>'0'))->save(array('ts_zt'=>'1'));
				die("<script>alert('投诉提交成功,请等待管理员审核通过！');parent.location.reload();</script>");
			}elseif($data_P['comfir']=='2'){
				M('ppdd')->where(array('id'=>$data_P['id'],'zt'=>'0'))->save(array('ts_zt'=>'0'));
				die("<script>alert('投诉取消成功,卖家可以继续汇款！');parent.location.reload();</script>");
			}
	
	
	
	
			
	
	
		}
	}

	public function home_ddxx_g_wqr_cl(){
	
		$data_P = I ( 'post.' );
	
	//dump($data_P);die;
	
	
		// 		$NowTime = '2015-07-01 01:56:17';
		// 		$aab=strtotime($NowTime);
		// 		$aab2=$aab+86400+86400;
	
		// 		echo "Today:",date('Y-m-d H:i:s',$aab),"<br>";
		// echo "Tomorrow:",date('Y-m-d H:i:s',$aab2);die;
	
	
	
	
	
	
	
		//echo strlen(trim($data_P['mesg']));die;
		$ppddxx=M('ppdd')->where(array('id'=>$data_P['id'],'zt'=>'1'))->find();
		$NowTime = $ppddxx['date_hk'];
		$aab=strtotime($NowTime);
		$aab2=$aab+86400+86400;
		$bba = date('Y-m-d H:i:s',time());
		$bba2=strtotime($bba);
	
		if ($ppddxx['p_user']<>$_SESSION['uname']) {
	
			die("<script>alert('非法操作！');history.back(-1);</script>");
		}elseif($aab2>$bba2) {
			die("<script>alert('确认时间未超过48时小,暂不能投诉,如未确认,请与对方取得联系！');history.back(-1);</script>");
		}elseif($data_P['comfir']<>'1'&&$data_P['comfir']<>'2') {
			die("<script>alert('请选择,确认或取消！');history.back(-1);</script>");
		}elseif($ppddxx['ts_zt']=='2') {
			die("<script>alert('您已被对方投诉,请与对方取得联系！');history.back(-1);</script>");
		}else{
			
			
			
			
			
			
			
			
			
		
			//dump($data_P);die;
			//echo strlen(trim($data_P['mesg']));die;
			
			
			
			
				if($data_P['comfir']=='1'){
			
					M('ppdd')->where(array('id'=>$data_P['id'],'zt'=>'1'))->save(array('zt'=>'2'));//更新此订单状态
			
					$txyqr=M('ppdd')->where(array('g_id'=>$ppddxx['g_id'],'zt'=>'2'))->sum('jb');
			
			
					$txzs=M('jsbz')->where(array('id'=>$ppddxx['g_id']))->find();
					if($txzs['jb']==$txyqr){
						M('jsbz')->where(array('id'=>$ppddxx['g_id']))->save(array('qr_zt'=>'1'));//提现订单已确认
					}
			
			
					$czyqr=M('ppdd')->where(array('p_id'=>$ppddxx['p_id'],'zt'=>'2'))->sum('jb');
			
			
					$czzs=M('tgbz')->where(array('id'=>$ppddxx['p_id']))->find();
					if($czzs['jb']==$czyqr){
						M('tgbz')->where(array('id'=>$ppddxx['p_id']))->save(array('qr_zt'=>'1'));//提现订单已确认
					}
			
			
			
					////更新提现订单状态
			
					//M('tgbz')->where(array('id'=>$ppddxx['p_id']))->setInc('jycg_ds',1);
			
					// 			    $tgbzcs=M('tgbz')->where(array('id'=>$ppddxx['p_id']))->find();
					// 			    if($tgbzcs['cf_ds']==$tgbzcs['jycg_ds']){
					// 			    	M('tgbz')->where(array('id'=>$ppddxx['p_id']))->save(array('qr_zt'=>'1'));//更新充值订单状态
					// 			    }
			
					//推荐奖10%
					 
					$tgbz_user_xx=M('user')->where(array('UE_account'=>$ppddxx['p_user']))->find();//充值人详细
					//echo $ppddxx['p_id'];die;
					if($tgbz_user_xx['ue_accname']<>''){
						$money=$ppddxx['jb']*0.1;
						$accname_zq=M('user')->where(array('UE_account'=>$tgbz_user_xx['ue_accname']))->find();
						M('user')->where(array('UE_account'=>$tgbz_user_xx['ue_accname']))->setInc('UE_money',$money);
						$accname_xz=M('user')->where(array('UE_account'=>$tgbz_user_xx['ue_accname']))->find();
						 						$note3 = "推荐奖10%";
						// added by skyrim
						// purpose: custom share
						// version: 6.0
						$settings = include( APP_PATH . 'Home/Conf/settings.php' );
						$note3 = "推荐奖" . ( floatval($settings['tjr_share']) ) . "%";
						$money=$ppddxx['jb']*10*floatval($settings['tjr_share'])/100;
						// added ends
						$record3 ["UG_account"] = $tgbz_user_xx['ue_accname']; // 登入转出账户
						$record3 ["UG_type"] = 'jb';
						$record3 ["UG_allGet"] = $accname_zq['ue_money']; // 金币
						$record3 ["UG_money"] = '+'.$money; //
						$record3 ["UG_balance"] = $accname_xz['ue_money']; // 当前推荐人的金币馀额
						$record3 ["UG_dataType"] = 'tjj'; // 金币转出
						$record3 ["UG_note"] = $note3; // 推荐奖说明
						$record3["UG_getTime"]		= date ( 'Y-m-d H:i:s', time () ); //操作时间
						$reg4 = M ( 'userget' )->add ( $record3 );
						 
						//$money_jlj1=;
						 
						// added by skyrim
						// purpose: custom share
						// version: 6.0
						$this_node = $tgbz_user_xx['ue_accname'];
						$i = $settings['max_jl_level'];
						while( $i -- ){
							if( $this_node && strlen( $this_node ) ){
							 $this_node = masses_j( $this_node, $ppddxx['jb']*floatval($settings['masses_share'][1+$settings['max_user_level']-$i]));
							}
						}
						
						$this_node = $tgbz_user_xx['ue_accname'];
						$i = $settings['max_jl_level'];
						while( $i -- ){
							if( $this_node && strlen( $this_node ) ){
								$this_node = jlj( $this_node, $ppddxx['jb']*floatval($settings['jl_share'][1+$settings['max_jl_level']-$i]), '经理奖' . ( floatval($settings['jl_share'][1+$settings['max_jl_level']-$i]) * 100 ) . '%' );
							}
						}
						// added ends
						// deleted by skyrim
						// purpose: custom share
						// version: 6.0
						// if($tgbz_user_xx['zcr']<>''){
						// 	$zcr2=jlj($tgbz_user_xx['zcr'],$ppddxx['jb']*0.05,'经理奖5%');
						// 	if($zcr2<>''){
						// 		$zcr3=jlj($zcr2,$ppddxx['jb']*0.03,'经理奖3%');
						// 		//echo $ppddxx['p_user'].'sadfsaf';die;
						// 		if($zcr3<>''){
						// 			$zcr4=jlj($zcr3,$ppddxx['jb']*0.01,'经理奖1%');
						// 			if($zcr4<>''){
						// 				$zcr5=jlj($zcr4,$ppddxx['jb']*0.0025,'经理奖0.25%');
						// 				if($zcr5<>''){
						// 					jlj($zcr5,$ppddxx['jb']*0.001,'经理奖0.1%');
						// 				}
						// 			}
						// 		}
						// 	}
						// }
						// deleted ends
						 
						 
						 
						 
						 
					}
					 
					 
					 
					 
					 
					 
					die("<script>alert('系统自动处理成功！');parent.location.reload();</script>");
			
			
				}
			
			
			
					

			
			
			
	
	
	
	
	
				
	
	
		}
	}
	
	public function tgbz_list_cf(){
	
	
		$User = M ( 'tgbz' ); // 实例化User对象
		$data = I ( 'post.user' );
	
		$this->z_jgbz=$User->sum('jb');
		$this->z_jgbz2=$User->where(array('qr_zt'=>'1'))->sum('jb');
		$this->z_jgbz3=$User->where(array('qr_zt'=>array('neq','1')))->sum('jb');
		//$map ['UG_dataType'] = array('IN',array('mrfh','tjj','kdj','mrldj','glj'));
	
		$map['zt']=0;
	
		if(I ( 'get.cz' )==1){
			$map['zt']=1;
		}
		if($data<>''){
			$map['user']=$data;
		}
		$count = $User->where ( $map )->count (); // 查询满足要求的总记录数
		//$page = new \Think\Page ( $count, 3 ); // 实例化分页类 传入总记录数和每页显示的记录数(25)
	
		$p = getpage($count,20);
	
		$list = $User->where ( $map )->order ( 'id DESC' )->limit ( $p->firstRow, $p->listRows )->select ();
		//dump($list);die;
		$this->assign ( 'list', $list ); // 赋值数据集
		$this->assign ( 'page', $p->show() ); // 赋值分页输出
	
	
	
		$this->display('index/tgbz_list_cf');
	}
	
	
	public function jsbz_list_cf(){
	
	
	
		$User = M ( 'jsbz' ); // 实例化User对象
		$data = I ( 'post.user' );
	
		$this->z_jgbz=$User->sum('jb');
		$this->z_jgbz2=$User->where(array('qr_zt'=>'1'))->sum('jb');
		$this->z_jgbz3=$User->where(array('qr_zt'=>array('neq','1')))->sum('jb');
		//$map ['UG_dataType'] = array('IN',array('mrfh','tjj','kdj','mrldj','glj'));
	
		$map['zt']=0;
	
		if(I ( 'get.cz' )==1){
			$map['zt']=1;
		}
		if($data<>''){
			$map['user']=$data;
		}
		$count = $User->where ( $map )->count (); // 查询满足要求的总记录数
		//$page = new \Think\Page ( $count, 3 ); // 实例化分页类 传入总记录数和每页显示的记录数(25)
	
		$p = getpage($count,20);
	
		$list = $User->where ( $map )->order ( 'id DESC' )->limit ( $p->firstRow, $p->listRows )->select ();
		//dump($list);die;
		$this->assign ( 'list', $list ); // 赋值数据集
		$this->assign ( 'page', $p->show() ); // 赋值分页输出
	
	
	
		$this->display('index/jsbz_list_cf');
	}
	
	public function tgbz_list_cf_cl(){
		$data=I('post.');
		$p_user=M('tgbz')->where(array('id'=>$data['pid']))->find();
		if (! preg_match ( '/^[0-9,]{1,100}$/', I('post.arrid') )) {
			$this->error( '格式不对!' );
			die;
		}
		$arr = explode(',',I('post.arrid'));
		//dump($arr);
		if(array_sum($arr)<>$p_user['jb']){
			$this->error( '拆分金额不对!' );
			die;
		}
	
    	// added by skyrim
    	// purpose: check money in range
    	// version: 4
		$settings = include( dirname( APP_PATH ) . '/User/Home/Conf/settings.php' );
		
		foreach( $arr as $q ){
			if( $settings['supply_money_upper_limit'] < $q || $q < $settings['supply_money_lower_limit'] ){
				$this->error('金额不在范围内!');
				
				return;
			}
		}
    	// added ends
	
	
	
		$p_user1=M('tgbz')->where(array('id'=>$data['pid']))->find();
	
		$pipeits=0;
		foreach($arr as $value){
			if($value<>''){
				$data2['zffs1']=$p_user1['zffs1'];
				$data2['zffs2']=$p_user1['zffs2'];
				$data2['zffs3']=$p_user1['zffs3'];
				$data2['user']=$p_user1['user'];
				$data2['jb']=$value;
				$data2['user_nc']=$p_user1['user_nc'];
				$data2['user_tjr']=$p_user1['user_tjr'];
				$data2['date']=$p_user1['date'];
				$data2['zt']=$p_user1['zt'];
				$data2['qr_zt']=$p_user1['qr_zt'];
				$varid = M('tgbz')->add($data2);
				$pipeits++;
			}
			 
	
		}
	
		M('tgbz')->where(array('id'=>$data['pid']))->delete();
	
	
	
	
		$this->success('匹配成功!拆分成'.$pipeits.'条订单!');
	}
	
	public function jsbz_list_cf_cl(){
		$data=I('post.');
		$p_user=M('jsbz')->where(array('id'=>$data['pid']))->find();
		if (! preg_match ( '/^[0-9,]{1,100}$/', I('post.arrid') )) {
			$this->error( '格式不对!' );
			die;
		}
		$arr = explode(',',I('post.arrid'));
		//dump($arr);
		if(array_sum($arr)<>$p_user['jb']){
			$this->error( '拆分金额不对!' );
			die;
		}
    	// added by skyrim
    	// purpose: check money in range
    	// version: 4
		$settings = include( dirname( APP_PATH ) . '/User/Home/Conf/settings.php' );
		
		foreach( $arr as $q ){
			if( $settings['supply_money_upper_limit'] < $q || $q < $settings['supply_money_lower_limit'] ){
				$this->error('金额不在范围内!');
				
				return;
			}
		}
    	// added ends
		 
		 
		 
		 
		$p_user1=M('jsbz')->where(array('id'=>$data['pid']))->find();
		 
		$pipeits=0;
		foreach($arr as $value){
			if($value<>''){
				$data2['zffs1']=$p_user1['zffs1'];
				$data2['zffs2']=$p_user1['zffs2'];
				$data2['zffs3']=$p_user1['zffs3'];
				$data2['user']=$p_user1['user'];
				$data2['jb']=$value;
				$data2['user_nc']=$p_user1['user_nc'];
				$data2['user_tjr']=$p_user1['user_tjr'];
				$data2['date']=$p_user1['date'];
				$data2['zt']=$p_user1['zt'];
				$data2['qr_zt']=$p_user1['qr_zt'];
				$varid = M('jsbz')->add($data2);
				$pipeits++;
			}
	
			 
		}
		 
		M('jsbz')->where(array('id'=>$data['pid']))->delete();
		 
		 
		 
		 
		$this->success('匹配成功!拆分成'.$pipeits.'条订单!');
	}
	 
	
}